import request from "./useRequests";
import { userinfo } from '@/stores/counter'
import { ElMessage } from 'element-plus'

export default function getPodcastIntros() {
    const user = userinfo()
    async function getIntros() {
        try {
            const res = await request({
                method: "get",
                url: `/back/getPodcastIntros`,
            })
            const intros = res.data.data
            for (let i = 0; i < intros.length; i++) {
                if (intros[i].belongTo == '解困播客') {
                    user.pages.podcast.intro = intros[i].content
                }
                else if (intros[i].belongTo == '解困者说') {
                    user.pages.saying.intro = intros[i].content
                }
                else if (intros[i].belongTo == '解困资源库') {
                    user.pages.res.intro = intros[i].content
                }
                else if (intros[i].belongTo == '我们的客厅') {
                    user.pages.roomIntro = intros[i].content
                }
            }
        } catch (err: any) {
            //alert(err)
        }
    }

    return {
        getIntros
    }
}